SERVER_NAME = server
CLIENT_NAME = client
SLICE_X86 = slice2cpp-x86
SLICE_ARM = slice2cpp-arm
CXX_ARM = arm-none-linux-gnueabi-g++
CXX_X86 = g++



ARM_COMMON_OBJS	:=	./arm/Imx.o
X86_COMMON_OBJS	:=	./x86/Imx.o
SERVER_OBJS :=	Server.o\
				global.o\
				ImxI.o\
				Notify.o\
				TaskControl.o\
				DataControl.o\
				Anlysis.o\
				Crc.o\
				Can.o
CLIENT_OBJS :=	Client.o

CXXFLAG_ARM = -g -I./ -I./arm -I../inc/ -I/root/ice-master-arm/cpp/include/
CXXFLAG_X86 = -g -I./ -I./x86 -I../inc/ -I/root/ice-master-x86/cpp/include/
LDFLAG_ARM = /root/ice-master-arm/cpp/lib/i386-linux-gnu/libIceUtil.so /root/ice-master-arm/cpp/lib/i386-linux-gnu/libIce.so
LDFLAG_X86 = /root/ice-master-x86/cpp/lib/i386-linux-gnu/libIceUtil.so /root/ice-master-x86/cpp/lib/i386-linux-gnu/libIce.so

all:: $(SERVER_NAME) $(CLIENT_NAME) install

x86/Imx.cpp x86/Imx.h: ../slice/Imx.ice
	rm -f x86/Imx.cpp x86/Imx.h
	$(SLICE_X86) ../slice/Imx.ice --output-dir ./x86
arm/Imx.cpp arm/Imx.h: ../slice/Imx.ice
	rm -f arm/Imx.cpp arm/Imx.h
	$(SLICE_ARM) ../slice/Imx.ice --output-dir ./arm
$(X86_COMMON_OBJS):%.o:%.cpp
	$(CXX_X86) -c $(CXXFLAG_X86) $< -o $@
$(ARM_COMMON_OBJS):%.o:%.cpp
	$(CXX_ARM) -c $(CXXFLAG_ARM) $< -o $@
$(SERVER_OBJS):%.o:%.cpp
	$(CXX_ARM) -c $(CXXFLAG_ARM) $< -o $@
$(CLIENT_OBJS):%.o:%.cpp
	$(CXX_X86) -c $(CXXFLAG_X86) $< -o $@

install:: $(SERVER_NAME)
	rm -f /nfsroot/$(SERVER_NAME)
	cp $(SERVER_NAME) /nfsroot/

$(SERVER_NAME):: $(ARM_COMMON_OBJS) $(SERVER_OBJS) $(LDFLAG_ARM)
	$(CXX_ARM) -o $@ $^
$(CLIENT_NAME):: $(X86_COMMON_OBJS) $(CLIENT_OBJS) $(LDFLAG_X86)
	$(CXX_X86) -o $@ $^
	


.PHONY:clean

clean:
	rm -rf *.o server client x86/Imx.* arm/Imx.*
	rm -rf /nfsroot/$(SERVER_NAME)
